<template>
	<view>
		<view class="mt-5" v-if="u_loadmore">
			<u-loadmore status="loading" icon-type="circle" />
		</view>
		<view v-else>
			<view class="m-2 px-3 py-1" v-if="mouse_detail.formated_total_fee">订单总金额(含运费):￥{{total.toFixed(2)}}</view>
			<view class="m-2 pl-3 bg-white rounded-20">
				<view class="d-flex d-flex border-bottom j-sb py-3">
					<view class="">现价</view>
					<view class="mr-3 font-weight font-35 text-muted"><input type="number"  v-model="going_price" class="u-text-right" placeholder="￥0.00"  placeholder-class="font-weight font-35 text-muted" @input="going"  /></view>
				</view>
				<view class="d-flex d-flex j-sb py-3">
					<view class="">现运费</view>
					<view class="mr-3 font-weight font-35 text-muted"><input type="number" v-model="carriage_price" class="u-text-right" placeholder="￥0.00"  placeholder-class="font-weight font-35 text-muted" @input="carriage" /></view>
				</view>
			</view>
			<view class="m-2 pl-3 bg-white rounded-20">
				<view class="d-flex d-flex j-sb py-3">
					<view class="">应付款金额</view>
					<view class="mr-3 font-weight font-35 text-danger">￥{{total==null?"0.00":total.toFixed(2)}}</view>
				</view>
			</view>
			<view class="bg-white py-2 w-100 position-fixed bottom-0 btn">
				<button type="warn" @click="confirm_price">确认改价</button>
			</view>
		</view>
	</view>
</template>
 
<script>
	export default {
		data() {
			return {
				mouse_detail:"", // 订单详情
				order_id:"", // 订单ID
				going_price:"", // 现价
				carriage_price:"" ,// 现运费
				u_loadmore:true, // 加载中
			}
		},
		onLoad(e) {
			this.order_id=e.order_id
			this.$H.post("admin/orders/detail",{id:e.order_id}).then(res=>{
				this.mouse_detail=res.data
				this.going_price=res.data.formated_goods_amount.replace("￥","") // 现价
				this.carriage_price=res.data.formated_shipping_fee.replace("￥","") // 现运费
				this.u_loadmore=false 
			})
		},
		computed:{
			total(){
				let num=0
				if(this.going_price==0){
					return num=parseFloat(this.carriage_price)
				}
				if(this.carriage_price==0){
					return num=parseFloat(this.going_price)
				}
				return num=parseFloat(this.going_price)+parseFloat(this.carriage_price)
			}
		},
		methods: {
			going(e){
				
				e.detail.value = (e.detail.value.match(/^\d*(\.?\d{0,2})/g)[0]) || 0.00
				this.$nextTick(()=>{
					this.going_price=e.detail.value
				})
				
			},
			carriage(e){
				e.detail.value = (e.detail.value.match(/^\d*(\.?\d{0,2})/g)[0]) || 0.00
				this.$nextTick(()=>{
					this.carriage_price=e.detail.value
				})
			},
			confirm_price(){
				this.$H.post("admin/order/operate/money",{order_id: this.order_id,goods_amount:this.going_price,shipping_fee:this.carriage_price}).then(res=>{
					uni.navigateBack({
						delta:1
					})
				})
			}
		}
	}
</script>

<style>
	.btn /deep/ button{
		width: 85%;
		font-weight: 700;
		border-radius: 50upx;
		background: linear-gradient(to right,#F31E3E,#FB4F37);
	}
</style>
